<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/vue.js"></script>
    <script src="js/velocity.js"></script>
    <style>
        /*.fade-enter-active,*/
        /*.fade-leave-active {*/
            /*-webkit-transition: opacity 3s;*/
            /*-moz-transition: opacity 3s;*/
            /*-ms-transition: opacity 3s;*/
            /*-o-transition: opacity 3s;*/
            /*transition: opacity 3s;*/
        /*}*/
    </style>
</head>
<body>
<div id="root">
    <transition
        name="fade"
        @before-enter="handleBeforeEnter"
        @enter="handleEnter"
        @after-enter="handleAfterEnter"
    >
        <div v-if="show">hello</div>
    </transition>
    <button @click="handleClick">切换</button>
</div>
<script>
    let vm = new Vue({
        el:"#root",
        data: {
            show: true
        },
        methods: {
            handleClick: function () {
                this.show = !this.show
            },
            handleBeforeEnter: function (el) {
                el.style.opacity = 0;
            },
            handleEnter: function (el, done) {
                Velocity(el, {opacity: 1}, {duration: 1000, complete: done})
                // setTimeout(function () {
                //     el.style.opacity = 1;
                // },1000)
                // setTimeout(function () {
                //     done()
                // },3000)
            },
            handleAfterEnter: function (el) {
                alert(1)
            }
        }
    })
</script>
</body>
</html>